#ifndef TRADERSPI_H
#define TRADERSPI_H

#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <map>
#include <unistd.h>
#include <algorithm>
#include <pthread.h>
#include <ThostFtdcTraderApi.h>
#include <iconv.h>  

class Tester : public CThostFtdcTraderSpi
{
public:
    Tester();    
    std::map<std::string,std::string> order;
    std::map<std::string,std::string> position;
	std::map<std::string,std::string> instruments;
    void OnFrontConnected();
    void OnRspUserLogin(CThostFtdcRspUserLoginField *Rtn,CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	void OnRspAuthenticate(CThostFtdcRspAuthenticateField *Rtn,CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
    void OnRspSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *Rtn, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	void OnRspQryInstrument(CThostFtdcInstrumentField *Rtn, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	void OnRspQryInstrumentMarginRate(CThostFtdcInstrumentMarginRateField *Rtn, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
	void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *Rtn, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
    void OnRspQryTradingAccount(CThostFtdcTradingAccountField *Rtn, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);    
    void OnRspQryInvestorPositionDetail(CThostFtdcInvestorPositionDetailField *Rtn, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
    void OnRspQryOrder(CThostFtdcOrderField *Rtn, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
    void OnRspOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
    void OnRspOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
    void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast);
    void OnRtnOrder(CThostFtdcOrderField *Rtn);
    void OnRtnTrade(CThostFtdcTradeField *Rtn);
    void OnFrontDisconnected(int nReason);
    void OnHeartBeatWarning(int nTimeLapse);
};

#endif
